<template>
  <view class="debug">
    <!-- <van-field
      :value="addForm.standingType"
      name="standingType"
      data-name="standingType"
      @click-input="showPicker = true"
      required
      clearable
      label="使用类型"
      placeholder="请选择使用类型"
      is-link
      readonly
    ></van-field>

    <van-popup :show="showPicker" position="bottom">
      <van-picker
        show-toolbar
        :columns="standingList"
        :value-key="value"
        @confirm="onConfirm"
        @cancel="showPicker = false"
      >
      </van-picker>
    </van-popup> -->

    <van-cell
      :title="title"
      :value="form[name]"
      @click="show = true"
    ></van-cell>
    <van-calendar
      :show="show"
      @close="onClose"
      @confirm="onConfirm"
    ></van-calendar>
  </view>
</template>
  
  <script>
export default {
  props: {
    title: String,
    form: [Object, String],
    name:String,
  },
  data() {
    return {
      show: false, //弹框的默认状态
    };
  },
  // 计算属性
  computed: {},

  methods: {
    // 日期转换
    formatDate(date) {
      date = new Date(date);
      return `${date.getMonth() + 1}/${date.getDate()}`;
    },
    // 关闭
    onClose() {
      this.show = false;
    },
    // 确认
    onConfirm(date) {
      console.log(date);
      this.form.time = this.formatDate(date.detail); //事件源里面的详情赋值给这个变量
      const {value,index} = date.detail
      this.$emit('change-time',this.name, this.form.time)
      this.show = false;
      console.log( this.form.time,' this.form.time---');

    },
  },
  mounted() {},
};
</script>
  
  <style lang="scss" ></style>